#include <iostream>
using namespace std;

typedef long long LL;
int cnt;

void emultiply(LL a, LL b){
    LL res = 1;
    cout << "case #"<<cnt++<<":"<<endl;
    if (b == 0){
        cout << 1 << endl;
        return;
    }
    for (int i = 0; i < b; i++)
    {
        res *= a;
    }
    cout << res<< endl;
    return;
}

int main(){
    int n;
    LL a, b;
    cin >> n;
    for (int i = 0; i < n; ++i){
        cin >> a >> b;
        emultiply(a,b);
    }
    return 0;
}